package com.tuanzi.loan.web.bean.credit;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.constants.DictionaryCode;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.credit.LoanCreditOrderRequest;
import com.tuanzi.loan.vo.response.credit.LoanCreditOrderResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.credit.LoanCreditOrderListLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.joda.time.DateTime;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.Date;
import java.util.List;

/**
 * User: liangZongXi
 * Create time: 10:39 2019/9/17
 * Description:
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanCreditOrderListBean extends JSFListingBean<LoanCreditOrderRequest, LoanCreditOrderResponse> {
    private static final long serialVersionUID = 2252036150394571142L;

    @PostConstruct
    private void init(){
        initLazyDataModel();
    }

    private void initLazyDataModel(){
        $ = new LoanCreditOrderRequest();
        $.setBeginDate(new DateTime().minusDays(2).toDate());
        $.setEndDate(new Date());
        lazyDataModel = new LoanCreditOrderListLazyDataModel($);
    }

    public void onReset(){
        initLazyDataModel();
    }

    @Override
    protected List<String> getDictionaryCodes() {
        return Lists.newArrayList(DictionaryCode.LARGE_COMMON_PRODUCT,
                DictionaryCode.LOAN_CREDIT_ORDER_STATUS, DictionaryCode.LOAN_CREDIT_PAY_CHANNEL);
    }
}
